﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;

namespace Hyt.Core
{
    public class QueryOption<T> where T:class
    {
        public QueryOption()
        {
            Includes = new List<string>();
        }
        /// <summary>
        /// 包含子表
        /// </summary>
        public List<string> Includes { get; set; }

        /// <summary>
        /// 启用状态跟踪
        /// </summary>
        public bool NoTracking { get; set; }

        /// <summary>
        /// 启用并行查询
        /// </summary>
        public bool Parallel { get; set; }

        /// <summary>
        /// 过滤条件
        /// </summary>
        public Expression<Func<T, bool>> Filter { get; set; }
    }

    public class QueryOption
    {
        public QueryOption()
        {
            Includes = new List<string>();
        }
        /// <summary>
        /// 包含子表
        /// </summary>
        public List<string> Includes { get; set; }

        /// <summary>
        /// 启用状态跟踪
        /// </summary>
        public bool NoTracking { get; set; }

        /// <summary>
        /// 启用并行查询
        /// </summary>
        public bool Parallel { get; set; }

        public QueryOption<T> Cast<T>() where T:class
        {
            QueryOption<T> ops = new QueryOption<T>()
            {
                Filter = null,
                Includes = new List<string>(this.Includes),
                NoTracking = NoTracking,
                Parallel = Parallel
            };
            return ops;
        }
    }
}
